<?php
/**
 * 获取数据库对象
 * @return PDO
 */
function connectDB(){
    $dsn = 'mysql:dbname=bibodb2;host=127.0.0.1';
    $user = 'root';
    $password = 'root';
    $db = new PDO($dsn, $user, $password);
    return $db;
}

$db=connectDB();
$res=$db->prepare('select id,username from bi_admin');
echo json_encode($res);